package cn.com.niit.controller;

import cn.com.niit.pojo.Merchant;
import cn.com.niit.pojo.User;
import cn.com.niit.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@CrossOrigin(origins = "*")
public class MerchantController {
    @Autowired
    MerchantService merchantService;
    @RequestMapping( "/showAllMerchant")
    public List<Merchant> showAll(Merchant merchant){
        if (merchant.getFlag().equals(""))
            merchant.setFlag(null);
        return merchantService.showAll(merchant);
    }
    @RequestMapping( "/fail")
    public void fail(String user_name){
        merchantService.fail(user_name);
    }
    @RequestMapping( "/ban")
    public void ban(String user_name){
        merchantService.ban(user_name);
    }
        @RequestMapping( "/unBan")
    public void unBan(String user_name){
        merchantService.unBan(user_name);
    }
    @GetMapping("/beComingMerchant")
    public String beComingMerchant(Merchant merchant){
        System.out.println(merchant);
        merchant.setFlag("2");
        merchantService.apply(merchant);
        return "index";
    }


}
